<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
    <meta name="viewport" content="width=device-width,
                                     initial-scale=1.0,
                                     maximum-scale=1.0,
                                     user-scalable=no">
    <title>ClassManage</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
          integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
            <link href="/css/common/AccountLoginPage.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="GreyPanel"></div>
<!-- cxcxzczx -->
<div class="ClassManage">课堂管理系统</div>
<div class="LoginWayOne"> <a href="#">账号密码登录</a></div>
<div class="LoginWayTwo"> <a href="/student/home">微信登录</a></div>
<div class="UserName"> 用户名</div>
<input type="text" class="UserNameField" id="username">
<div class="Password"> 密码</div>
<input type="password" class="PasswordField" id="password">
<button class="Login" id="submit">登录</button>
<div class="Enroll"><a href="/student/bind">注册</a></div>
<script>
    localStorage.clear();
    (function () {
        $("#submit").click(function () {
            var data = {
                phone: $("#username").val(),
                password: $("#password").val()
            };
            $.ajax({
                url: "/login",
                type: "POST",
                data: JSON.stringify(data),
                contentType: "application/json; charset=UTF-8",
                success: function (data) {
                    localStorage.setItem("jwt", data.jwt);
                    localStorage.setItem("userId",data.id);
                    if (data.type == "student") {
                        window.location.href="/student/home";
                    } else {
                        window.location.href="teacher/home";
                    }
                }
            })
        })
    })();
</script>
</body>
</html>